#include "UdpServer.hpp"
#include "Route.hpp"

//./udpserver port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        exit(1);
    }
    uint16_t port = std::stoi(argv[1]);

    // 1. 提供路由功能
    Route r;

    // 2.服务器对象提供网络通信功能

    std::unique_ptr<UdpServer> usvr = std::make_unique<UdpServer>(port, [&r](int sockfd, std::string &message){
        r.SendMessage(sockfd, message);
    });
    usvr->Init();
    usvr->Start();

    return 0;
}